import arbori.*;
import functii.*;
import operatori.*;

public class Main {
public static void main(String[] args) {

/*Nod n=new Necunoscuta();
Nod sin=new Sin();
Nod cos=new Cos();
Nod xn=new Necunoscuta();
Nod cat=new Cat();
cat.setfStang(n);
cat.setfDrept(sin);
sin.setfStang(cos);
cos.setfStang(xn);
ArboreFunctional a=new ArboreFunctional(cat);
System.out.println(a.derivata());*/

	//exemplu cu Plus: f(x)=x+3.0
	Nod nec = new Necunoscuta();
    Nod cons = new Constanta(3);
    Nod plus = new Plus();
    
    plus.setfStang(nec);
    plus.setfDrept(cons);
    
    ArboreFunctional a=new ArboreFunctional(plus);
    
    System.out.println("Functia este: f(x)="+a);
	System.out.println("Derivata este: f'(x)="+a.derivata());
	System.out.println("f(4)="+a.calculezValoare(4));
	System.out.println("f'(3)="+a.calculezDerivata(3));
	System.out.println();
	
	//exemplu cu Produs: f(x)=4.0*x
	Nod n1=new Necunoscuta();
	Nod c1=new Constanta(4);	
	Nod prod=new Produs();
	
	prod.setfStang(c1);
	prod.setfDrept(n1);
			
	ArboreFunctional a2=new ArboreFunctional(prod);
			
	System.out.println("Functia este: f(x)="+a2);
	System.out.println("Derivata este: f'(x)="+a2.derivata());
	System.out.println("f(2)="+a2.calculezValoare(2));
	System.out.println("f'(3)="+a2.calculezDerivata(3));
	System.out.println();
	
	//exemplu cu Produs, Plus si Minus: f(x)=(x+2)*(x-3)
	Nod n2=new Necunoscuta();
	Nod c2=new Constanta(2);	
	Nod plus2=new Plus();
	
	plus2.setfStang(n2);
	plus2.setfDrept(c2);
			
	Nod n3=new Necunoscuta();
	Nod c3=new Constanta(3);	
	Nod minus=new Minus();
	
	minus.setfStang(n3);
	minus.setfDrept(c3);
			
	Nod produs=new Produs();		
	produs.setfStang(plus2);
	produs.setfDrept(minus);
			
	ArboreFunctional a3=new ArboreFunctional(produs);
			
	System.out.println("Functia este: f(x)="+a3);
	System.out.println("Derivata este: f'(x)="+a3.derivata());
	System.out.println("f(5)="+a3.calculezValoare(5));
	System.out.println("f'(2)="+a3.calculezDerivata(2));
	System.out.println();
	
	//exemplu cu Cat si Plus: f(x)=(3+x)/2
	
	Nod n4=new Necunoscuta();
	Nod c4=new Constanta(3);
	Nod plus3=new Plus();
	
	plus3.setfStang(c4);
	plus3.setfDrept(n4);
	
	Nod c5=new Constanta(2);
	Nod cat=new Cat();
			
	cat.setfStang(plus3);
	cat.setfDrept(c5);
			
	ArboreFunctional a4=new ArboreFunctional(cat);
			
	System.out.println("Functia este: f(x)="+a4);
	System.out.println("Derivata este: f'(x)="+a4.derivata());
	System.out.println("f(5)="+a4.calculezValoare(5));
	System.out.println("f'(2)="+a4.calculezDerivata(2));
	System.out.println();
	
	//exemplu cu Sin: f(x)=sin(x+1)
	Nod n7=new Necunoscuta();
	Nod c7=new Constanta(1);
	Nod plus4=new Plus();
	plus4.setfStang(n7);
	plus4.setfDrept(c7);
	Nod sin=new Sin();
	sin.setfStang(plus4);
			
	ArboreFunctional a5=new ArboreFunctional(sin);
			
	System.out.println("Functia este: f(x)="+a5);
	System.out.println("Derivata este: f'(x)="+a5.derivata());
	System.out.println("f(5)="+a5.calculezValoare(5));
	System.out.println("f'(2)="+a5.calculezDerivata(2));
	System.out.println();
	
	//exemplu cu Cos: f(x)=cos(x)
	Nod n8=new Necunoscuta();
	Nod cos=new Cos();
	cos.setfStang(n8);
			
	ArboreFunctional a6=new ArboreFunctional(cos);
			
	System.out.println("Functia este: f(x)="+a6);
	System.out.println("Derivata este: f'(x)="+a6.derivata());
	System.out.println("f(5)="+a6.calculezValoare(5));
	System.out.println("f'(2)="+a6.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu Tangenta: f(x)=tg(x)
	Nod n9=new Necunoscuta();
	Nod tan=new Tangenta();
	tan.setfStang(n9);
			
	ArboreFunctional a7=new ArboreFunctional(tan);
			
	System.out.println("Functia este: f(x)="+a7);
	System.out.println("Derivata este: f'(x)="+a7.derivata());
	System.out.println("f(5)="+a7.calculezValoare(5));
	System.out.println("f'(2)="+a7.calculezDerivata(2));
	System.out.println();
	
	//exemplu cu Cotangenta: f(x)=ctg(x)
	Nod n10=new Necunoscuta();
	Nod ctan=new Ctg();
	ctan.setfStang(n10);
			
	ArboreFunctional a8=new ArboreFunctional(ctan);
			
	System.out.println("Functia este: f(x)="+a8);
	System.out.println("Derivata este: f'(x)="+a8.derivata());
	System.out.println("f(5)="+a8.calculezValoare(5));
	System.out.println("f'(2)="+a8.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu arccos: f(x)=arccos(x)
	Nod n11=new Necunoscuta();
	Nod arccos=new Arccos();
	arccos.setfStang(n11);
			
	ArboreFunctional a9=new ArboreFunctional(arccos);
			
	System.out.println("Functia este: f(x)="+a9);
	System.out.println("Derivata este: f'(x)="+a9.derivata());
	System.out.println("f(5)="+a9.calculezValoare(5));
	System.out.println("f'(2)="+a9.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu arcctg: f(x)=arcctg(x)
	Nod n12=new Necunoscuta();
	Nod arcctg=new Arcctg();
	arcctg.setfStang(n12);
			
	ArboreFunctional a10=new ArboreFunctional(arcctg);
			
	System.out.println("Functia este: f(x)="+a10);
	System.out.println("Derivata este: f'(x)="+a10.derivata());
	System.out.println("f(5)="+a10.calculezValoare(5));
	System.out.println("f'(2)="+a10.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu arcsin: f(x)=arcsin(x)
	Nod n13=new Necunoscuta();
	Nod arcsin=new Arcsin();
	arcsin.setfStang(n13);
			
	ArboreFunctional a11=new ArboreFunctional(arcsin);
			
	System.out.println("Functia este: f(x)="+a11);
	System.out.println("Derivata este: f'(x)="+a11.derivata());
	System.out.println("f(5)="+a11.calculezValoare(5));
	System.out.println("f'(2)="+a11.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu arctg: f(x)=arctg(x)
	Nod n14=new Necunoscuta();
	Nod arctg=new Arctg();
	arctg.setfStang(n14);
			
	ArboreFunctional a12=new ArboreFunctional(arctg);
			
	System.out.println("Functia este: f(x)="+a12);
	System.out.println("Derivata este: f'(x)="+a12.derivata());
	System.out.println("f(5)="+a12.calculezValoare(5));
	System.out.println("f'(2)="+a12.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu exponentiala: f(x)=exp(x)
	Nod n15=new Necunoscuta();
	Nod exp=new Exp();
	exp.setfStang(n15);
			
	ArboreFunctional a13=new ArboreFunctional(exp);
			
	System.out.println("Functia este: f(x)="+a13);
	System.out.println("Derivata este: f'(x)="+a13.derivata());
	System.out.println("f(5)="+a13.calculezValoare(5));
	System.out.println("f'(2)="+a13.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu logaritm: f(x)=log(x)
	Nod n16=new Necunoscuta();
	Nod log=new Log();
	log.setfStang(n16);
			
	ArboreFunctional a14=new ArboreFunctional(log);
			
	System.out.println("Functia este: f(x)="+a14);
	System.out.println("Derivata este: f'(x)="+a14.derivata());
	System.out.println("f(5)="+a14.calculezValoare(5));
	System.out.println("f'(2)="+a14.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu putere: f(x)=pow(x)
	Nod n17=new Necunoscuta();
    Nod pow=new Putere();
	pow.setfStang(n17);
			
	ArboreFunctional a15=new ArboreFunctional(pow);
			
	System.out.println("Functia este: f(x)="+a15);
	System.out.println("Derivata este: f'(x)="+a15.derivata());
	System.out.println("f(5)="+a15.calculezValoare(5));
	System.out.println("f'(2)="+a15.calculezDerivata(2));
	System.out.println();
			
	//exemplu cu radical: f(x)=sqrt(x)
	Nod n18=new Necunoscuta();
	Nod sqrt=new Radical();
	sqrt.setfStang(n18);
			
	ArboreFunctional a16=new ArboreFunctional(sqrt);
			
	System.out.println("Functia este: f(x)="+a16);
	System.out.println("Derivata este: f'(x)="+a16.derivata());
	System.out.println("f(5)="+a16.calculezValoare(5));
	System.out.println("f'(2)="+a16.calculezDerivata(2));
	System.out.println();
	
	
	
	//exemplu: f(x)=sinH(x)
	Nod n19=new Necunoscuta();
	Nod stea=new SinH();
	stea.setfStang(n19);
			
	ArboreFunctional a17=new ArboreFunctional(stea);
			
	System.out.println("Functia este: f(x)="+a17);
	System.out.println("Derivata este: f'(x)="+a17.derivata());
	System.out.println("f(5)="+a17.calculezValoare(5));
	System.out.println("f'(2)="+a17.calculezDerivata(2));
	System.out.println();
	
	//exemplu cu stea stea: f(x)=sqrt(x)**SinH(x)+x^2
	
	System.out.println("*************************************");
	
		
	/*	Nod n20=new Necunoscuta();
		Nod n21=new Necunoscuta();
		
		
		Nod star=new Steluta_steluta();
		
		star.setfStang(n20);
		star.setfDrept(n21);
		
				
			
		Nod plus20=new Plus();
		
		Nod c20=new Constanta(Math.PI);		
				
		plus20.setfStang(star);
		plus20.setfDrept(c20);
				
		ArboreFunctional a20=new ArboreFunctional(plus20);
				
		System.out.println("Functia este: f(x)="+a20);
		System.out.println("Derivata este: f'(x)="+a20.derivata());
		System.out.println("f(5)="+a20.calculezValoare(5));
		System.out.println("f'(2)="+a20.calculezDerivata(2));
		System.out.println();*/
	
	//exemplu 3: f(x)=sqrt(x)**sinH(x)+x^2
	
	//exemplu cu Produs, Plus si Minus: f(x)=(x+2)*(x-3)
	
	//exemplu cu radical: f(x)=sqrt(x)
		Nod n20=new Necunoscuta();
		Nod sqrt1=new Radical();
		sqrt1.setfStang(n20);
				
	//sh(x) +x^2
		
		Nod n21=new Necunoscuta();
		Nod sinh1=new SinH();
		sinh1.setfStang(n21);
		
	//exemplu cu putere: f(x)=pow(x)
		Nod n22=new Necunoscuta();
	    Nod pow1=new Putere();
		pow1.setfStang(n22);
		
		Nod plus20
		
		
		Nod n2=new Necunoscuta();
		Nod c2=new Constanta(2);	
		Nod plus2=new Plus();
		
		plus2.setfStang(n2);
		plus2.setfDrept(c2);
				
		Nod n3=new Necunoscuta();
		Nod c3=new Constanta(3);	
		Nod minus=new Minus();
		
		minus.setfStang(n3);
		minus.setfDrept(c3);
				
		Nod produs=new Produs();		
		produs.setfStang(plus2);
		produs.setfDrept(minus);
				
		ArboreFunctional a3=new ArboreFunctional(produs);
				
		System.out.println("Functia este: f(x)="+a3);
		System.out.println("Derivata este: f'(x)="+a3.derivata());
		System.out.println("f(5)="+a3.calculezValoare(5));
		System.out.println("f'(2)="+a3.calculezDerivata(2));
		System.out.println();
		
		
  }
}